home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWStream / Include / FWStrmRW.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  31.3 KB  |  1,029 lines  |  [TEXT/MPS ]

  1. #ifndef FWSTRMRW_H
  2. #define FWSTRMRW_H
  3. //========================================================================================
  4. //
  5. //    File:                FWStrmRW.h
  6. //    Release Version:    $ 1.0d1 $
  7. //
  8. //    Creation Date:        3/28/94
  9. //
  10. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //========================================================================================
  13.  
  14. #ifndef FWASINKS_H
  15. #include "FWASinks.h"
  16. #endif
  17.  
  18. #ifndef FWSTRMF_H
  19. #include "FWStrmF.h"
  20. #endif
  21.  
  22. //========================================================================================
  23. //    CLASS FW_CReadableStream
  24. //========================================================================================
  25.  
  26. class FW_CReadableStream : public _FW_CAutoDestructObject
  27. {
  28.  
  29. public:
  30.  
  31.     FW_CReadableStream(FW_CSink* sink,
  32.                        FW_CReadableStreamFormatter* formatter = 0);
  33.     ~FW_CReadableStream();
  34.  
  35.     // ----- void
  36.     
  37.     void Read(void* buffer,
  38.               long count) const;
  39.         // Read 'count' bytes into buffer.
  40.  
  41.     // ----- char
  42.     
  43. #if !defined(__BORLANDC__)
  44.     // Borland doesn't treat char, unsigned char and signed char as three distinct types
  45.     // as it should. (ARM pg. 22)
  46.     void Read(char* buffer,
  47.               long count) const;
  48.         // Read 'count' chars into buffer.
  49.  
  50.     const FW_CReadableStream& operator>>(char& aChar) const;
  51.         // Read char.
  52. #endif
  53.  
  54.     const FW_CReadableStream& operator>>(char* nullTerminatedString) const;
  55.         // Read a null-terminated string.
  56.         
  57.     char GetChar() const;
  58.         // Get char.
  59.  
  60.     // ----- signed char
  61.     
  62.     void Read(signed char* buffer,
  63.               long count) const;
  64.         // Read 'count' signed chars into buffer.
  65.  
  66.     const FW_CReadableStream& operator>>(signed char& aChar) const;
  67.         // Read char.
  68.  
  69.     signed char GetSignedChar() const;
  70.         // Get signed char.
  71.  
  72.     // ----- unsigned char
  73.     
  74.     void Read(unsigned char* buffer,
  75.               long count) const;
  76.         // Read 'count' unsigned chars into buffer.
  77.  
  78.     const FW_CReadableStream& operator>>(unsigned char& aChar) const;
  79.         // Read char.
  80.  
  81.     unsigned char GetUnsignedChar() const;
  82.         // Get unsigned char.
  83.  
  84.     // ----- int
  85.  
  86.     void Read(int* buffer,
  87.               long count) const;
  88.         // Read 'count' ints into buffer.
  89.  
  90.     const FW_CReadableStream& operator>>(int& aInt) const;
  91.         // Read int.
  92.  
  93.     int GetInt() const;
  94.         // Get int.
  95.  
  96.     // ----- unsigned int
  97.  
  98.     void Read(unsigned int* buffer,
  99.               long count) const;
  100.         // Read 'count' unsigned ints into buffer.
  101.  
  102.     const FW_CReadableStream& operator>>(unsigned int& unsignedInt) const;
  103.         // Read unsigned int.
  104.  
  105.     unsigned int GetUnsignedInt() const;
  106.         // Get unsigned int.
  107.  
  108.     // ----- short
  109.  
  110.     void Read(short* buffer,
  111.               long count) const;
  112.         // Read 'count' shorts into buffer.
  113.  
  114.     const FW_CReadableStream& operator>>(short& aShort) const;
  115.         // Read short.
  116.  
  117.     short GetShort() const;
  118.         // Get short.
  119.  
  120.     // ----- unsigned short
  121.  
  122.     void Read(unsigned short* buffer,
  123.               long count) const;
  124.         // Read 'count' unsigned shorts into buffer.
  125.  
  126.     const FW_CReadableStream& operator>>(unsigned short& unsignedShort) const;
  127.         // Read unsigned short.
  128.  
  129.     unsigned short GetUnsignedShort() const;
  130.         // Get unsigned short.
  131.  
  132.     // ----- long
  133.  
  134.     void Read(long* buffer,
  135.               long count) const;
  136.         // Read 'count' longs into buffer.
  137.  
  138.     const FW_CReadableStream& operator>>(long& aLong) const;
  139.         // Read long.
  140.  
  141.     long GetLong() const;
  142.         // Get long.
  143.  
  144.     // ----- unsigned long
  145.  
  146.     void Read(unsigned long* buffer,
  147.               long count) const;
  148.         // Read 'count' unsigned longs into buffer.
  149.  
  150.     const FW_CReadableStream& operator>>(unsigned long& unsignedLong) const;
  151.         // Read unsigned long.
  152.  
  153.     unsigned long GetUnsignedLong() const;
  154.         // Get unsigned long.
  155.  
  156.     // ----- float
  157.  
  158.     void Read(float* buffer,
  159.               long count) const;
  160.         // Read 'count' floats into buffer.
  161.  
  162.     const FW_CReadableStream& operator>>(float& aFloat) const;
  163.         // Read float.
  164.  
  165.     float GetFloat() const;
  166.         // Get float.
  167.  
  168.     // ----- double
  169.  
  170.     void Read(double* buffer,
  171.               long count) const;
  172.         // Read 'count' doubles into buffer.
  173.  
  174.     const FW_CReadableStream& operator>>(double& aDouble) const;
  175.         // Read double.
  176.  
  177.     double GetDouble() const;
  178.         // Get double.
  179.         
  180. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  181.  
  182.     // ----- long double
  183.     
  184.     void Read(long double* buffer,
  185.               long count) const;
  186.         // Read 'count' long doubles into buffer.
  187.  
  188.     const FW_CReadableStream& operator>>(long double& aDouble) const;
  189.         // Read long double.
  190.  
  191.     long double GetLongDouble() const;
  192.         // Get long double.
  193. #endif
  194.  
  195. protected:
  196.  
  197.     FW_CSink* fSink;
  198.     FW_Boolean fStreamCreatedFormatter;
  199.     FW_CReadableStreamFormatter* fFormatter;
  200.     
  201. private:
  202.     FW_CReadableStream(const FW_CReadableStream& theStream);
  203.     FW_CReadableStream& operator=(const FW_CReadableStream& theStream);
  204.         // Can't copy instances of this class.
  205. };
  206.  
  207. //----------------------------------------------------------------------------------------
  208. // FW_CReadableStream::Read
  209. //----------------------------------------------------------------------------------------
  210.  
  211. inline void FW_CReadableStream::Read(void* buffer,
  212.                                      long count) const
  213. {
  214.     fFormatter->ReadBytes(*fSink, buffer, count);
  215. }
  216.  
  217. #if !defined(__BORLANDC__)
  218. //----------------------------------------------------------------------------------------
  219. // FW_CReadableStream::Read
  220. //----------------------------------------------------------------------------------------
  221.  
  222. inline void FW_CReadableStream::Read(char* buffer,
  223.                                      long count) const
  224. {
  225.     fFormatter->ReadChars(*fSink, buffer, count);
  226. }
  227. #endif
  228.  
  229. #if !defined(__BORLANDC__)
  230. //----------------------------------------------------------------------------------------
  231. // FW_CReadableStream::operator >>
  232. //----------------------------------------------------------------------------------------
  233.  
  234. inline const FW_CReadableStream& FW_CReadableStream::operator>>(char& aChar) const
  235. {
  236.     fFormatter->ReadChars(*fSink, &aChar, 1);
  237.     return *this;
  238. }
  239. #endif
  240.  
  241. //----------------------------------------------------------------------------------------
  242. // FW_CReadableStream::operator >>
  243. //----------------------------------------------------------------------------------------
  244.  
  245. inline const FW_CReadableStream& FW_CReadableStream::operator>>(char* nullTerminatedString) const
  246. {
  247.     fFormatter->ReadNullTerminatedString(*fSink, nullTerminatedString);
  248.     return *this;
  249. }
  250.  
  251. //----------------------------------------------------------------------------------------
  252. // FW_CReadableStream::GetChar
  253. //----------------------------------------------------------------------------------------
  254.  
  255. inline char FW_CReadableStream::GetChar() const
  256. {
  257.     char x;
  258.     fFormatter->ReadChars(*fSink, &x, 1);
  259.     return x;
  260. }
  261.  
  262. //----------------------------------------------------------------------------------------
  263. // FW_CReadableStream::Read
  264. //----------------------------------------------------------------------------------------
  265.  
  266. inline void FW_CReadableStream::Read(signed char* buffer,
  267.                                      long count) const
  268. {
  269.     fFormatter->ReadSignedChars(*fSink, buffer, count);
  270. }
  271.  
  272. //----------------------------------------------------------------------------------------
  273. // FW_CReadableStream::operator >>
  274. //----------------------------------------------------------------------------------------
  275.  
  276. inline const FW_CReadableStream& FW_CReadableStream::operator>>(signed char& aChar) const
  277. {
  278.     fFormatter->ReadSignedChars(*fSink, &aChar, 1);
  279.     return *this;
  280. }
  281.  
  282. //----------------------------------------------------------------------------------------
  283. // FW_CReadableStream::GetSignedChar
  284. //----------------------------------------------------------------------------------------
  285.  
  286. inline signed char FW_CReadableStream::GetSignedChar() const
  287. {
  288.     signed char x;
  289.     fFormatter->ReadSignedChars(*fSink, &x, 1);
  290.     return x;
  291. }
  292.  
  293. //----------------------------------------------------------------------------------------
  294. // FW_CReadableStream::Read
  295. //----------------------------------------------------------------------------------------
  296.  
  297. inline void FW_CReadableStream::Read(unsigned char* buffer,
  298.                                      long count) const
  299. {
  300.     fFormatter->ReadUnsignedChars(*fSink, buffer, count);
  301. }
  302.  
  303. //----------------------------------------------------------------------------------------
  304. // FW_CReadableStream::operator >>
  305. //----------------------------------------------------------------------------------------
  306.  
  307. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned char& aChar) const
  308. {
  309.     fFormatter->ReadUnsignedChars(*fSink, &aChar, 1);
  310.     return *this;
  311. }
  312.  
  313. //----------------------------------------------------------------------------------------
  314. // FW_CReadableStream::GetUnsignedChar
  315. //----------------------------------------------------------------------------------------
  316.  
  317. inline unsigned char FW_CReadableStream::GetUnsignedChar() const
  318. {
  319.     unsigned char x;
  320.     fFormatter->ReadUnsignedChars(*fSink, &x, 1);
  321.     return x;
  322. }
  323.  
  324. //----------------------------------------------------------------------------------------
  325. // FW_CReadableStream::Read
  326. //----------------------------------------------------------------------------------------
  327.  
  328. inline void FW_CReadableStream::Read(int* buffer,
  329.                                      long count) const
  330. {
  331.     fFormatter->ReadInts(*fSink, buffer, count);
  332. }
  333.  
  334. //----------------------------------------------------------------------------------------
  335. // FW_CReadableStream::operator >>
  336. //----------------------------------------------------------------------------------------
  337.  
  338. inline const FW_CReadableStream& FW_CReadableStream::operator>>(int& aInt) const
  339. {
  340.     fFormatter->ReadInts(*fSink, &aInt, 1);
  341.     return *this;
  342. }
  343.  
  344. //----------------------------------------------------------------------------------------
  345. // FW_CReadableStream::GetInt
  346. //----------------------------------------------------------------------------------------
  347.  
  348. inline int FW_CReadableStream::GetInt() const
  349. {
  350.     int x;
  351.     fFormatter->ReadInts(*fSink, &x, 1);
  352.     return x;
  353. }
  354.  
  355. //----------------------------------------------------------------------------------------
  356. // FW_CReadableStream::Read
  357. //----------------------------------------------------------------------------------------
  358.  
  359. inline void FW_CReadableStream::Read(unsigned int* buffer,
  360.                                      long count) const
  361. {
  362.     fFormatter->ReadUnsignedInts(*fSink, buffer, count);
  363. }
  364.  
  365. //----------------------------------------------------------------------------------------
  366. // FW_CReadableStream::operator >>
  367. //----------------------------------------------------------------------------------------
  368.  
  369. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned int& unsignedInt) const
  370. {
  371.     fFormatter->ReadUnsignedInts(*fSink, &unsignedInt, 1);
  372.     return *this;
  373. }
  374.  
  375. //----------------------------------------------------------------------------------------
  376. // FW_CReadableStream::GetUnsignedInt
  377. //----------------------------------------------------------------------------------------
  378.  
  379. inline unsigned int FW_CReadableStream::GetUnsignedInt() const
  380. {
  381.     unsigned int x;
  382.     fFormatter->ReadUnsignedInts(*fSink, &x, 1);
  383.     return x;
  384. }
  385.  
  386. //----------------------------------------------------------------------------------------
  387. // FW_CReadableStream::Read
  388. //----------------------------------------------------------------------------------------
  389.  
  390. inline void FW_CReadableStream::Read(short* buffer,
  391.                                      long count) const
  392. {
  393.     fFormatter->ReadShorts(*fSink, buffer, count);
  394. }
  395.  
  396. //----------------------------------------------------------------------------------------
  397. // FW_CReadableStream::operator >>
  398. //----------------------------------------------------------------------------------------
  399.  
  400. inline const FW_CReadableStream& FW_CReadableStream::operator>>(short& aShort) const
  401. {
  402.     fFormatter->ReadShorts(*fSink, &aShort, 1);
  403.     return *this;
  404. }
  405.  
  406. //----------------------------------------------------------------------------------------
  407. // FW_CReadableStream::GetShort
  408. //----------------------------------------------------------------------------------------
  409.  
  410. inline short FW_CReadableStream::GetShort() const
  411. {
  412.     short x;
  413.     fFormatter->ReadShorts(*fSink, &x, 1);
  414.     return x;
  415. }
  416.  
  417. //----------------------------------------------------------------------------------------
  418. // FW_CReadableStream::Read
  419. //----------------------------------------------------------------------------------------
  420.  
  421. inline void FW_CReadableStream::Read(unsigned short* buffer,
  422.                                      long count) const
  423. {
  424.     fFormatter->ReadUnsignedShorts(*fSink, buffer, count);
  425. }
  426.  
  427. //----------------------------------------------------------------------------------------
  428. // FW_CReadableStream::operator >>
  429. //----------------------------------------------------------------------------------------
  430.  
  431. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned short& unsignedShort) const
  432. {
  433.     fFormatter->ReadUnsignedShorts(*fSink, &unsignedShort, 1);
  434.     return *this;
  435. }
  436.  
  437. //----------------------------------------------------------------------------------------
  438. // FW_CReadableStream::GetUnsignedShort
  439. //----------------------------------------------------------------------------------------
  440.  
  441. inline unsigned short FW_CReadableStream::GetUnsignedShort() const
  442. {
  443.     unsigned short x;
  444.     fFormatter->ReadUnsignedShorts(*fSink, &x, 1);
  445.     return x;
  446. }
  447.  
  448. //----------------------------------------------------------------------------------------
  449. // FW_CReadableStream::Read
  450. //----------------------------------------------------------------------------------------
  451.  
  452. inline void FW_CReadableStream::Read(long* buffer,
  453.                                      long count) const
  454. {
  455.     fFormatter->ReadLongs(*fSink, buffer, count);
  456. }
  457.  
  458. //----------------------------------------------------------------------------------------
  459. // FW_CReadableStream::operator >>
  460. //----------------------------------------------------------------------------------------
  461.  
  462. inline const FW_CReadableStream& FW_CReadableStream::operator>>(long& aLong) const
  463. {
  464.     fFormatter->ReadLongs(*fSink, &aLong, 1);
  465.     return *this;
  466. }
  467.  
  468. //----------------------------------------------------------------------------------------
  469. // FW_CReadableStream::GetLong
  470. //----------------------------------------------------------------------------------------
  471.  
  472. inline long FW_CReadableStream::GetLong() const
  473. {
  474.     long x;
  475.     fFormatter->ReadLongs(*fSink, &x, 1);
  476.     return x;
  477. }
  478.  
  479. //----------------------------------------------------------------------------------------
  480. // FW_CReadableStream::Read
  481. //----------------------------------------------------------------------------------------
  482.  
  483. inline void FW_CReadableStream::Read(unsigned long* buffer,
  484.                                      long count) const
  485. {
  486.     fFormatter->ReadUnsignedLongs(*fSink, buffer, count);
  487. }
  488.  
  489. //----------------------------------------------------------------------------------------
  490. // FW_CReadableStream::operator >>
  491. //----------------------------------------------------------------------------------------
  492.  
  493. inline const FW_CReadableStream& FW_CReadableStream::operator>>(unsigned long& unsignedLong) const
  494. {
  495.     fFormatter->ReadUnsignedLongs(*fSink, &unsignedLong, 1);
  496.     return *this;
  497. }
  498.  
  499. //----------------------------------------------------------------------------------------
  500. // FW_CReadableStream::GetUnsignedLong
  501. //----------------------------------------------------------------------------------------
  502.  
  503. inline unsigned long FW_CReadableStream::GetUnsignedLong() const
  504. {
  505.     unsigned long x;
  506.     fFormatter->ReadUnsignedLongs(*fSink, &x, 1);
  507.     return x;
  508. }
  509.  
  510. //----------------------------------------------------------------------------------------
  511. // FW_CReadableStream::Read
  512. //----------------------------------------------------------------------------------------
  513.  
  514. inline void FW_CReadableStream::Read(float* buffer,
  515.                                      long count) const
  516. {
  517.     fFormatter->ReadFloats(*fSink, buffer, count);
  518. }
  519.  
  520. //----------------------------------------------------------------------------------------
  521. // FW_CReadableStream::operator >>
  522. //----------------------------------------------------------------------------------------
  523.  
  524. inline const FW_CReadableStream& FW_CReadableStream::operator>>(float& aFloat) const
  525. {
  526.     fFormatter->ReadFloats(*fSink, &aFloat, 1);
  527.     return *this;
  528. }
  529.  
  530. //----------------------------------------------------------------------------------------
  531. // FW_CReadableStream::GetFloat
  532. //----------------------------------------------------------------------------------------
  533.  
  534. inline float FW_CReadableStream::GetFloat() const
  535. {
  536.     float x;
  537.     fFormatter->ReadFloats(*fSink, &x, 1);
  538.     return x;
  539. }
  540.  
  541. //----------------------------------------------------------------------------------------
  542. // FW_CReadableStream::Read
  543. //----------------------------------------------------------------------------------------
  544.  
  545. inline void FW_CReadableStream::Read(double* buffer,
  546.                                      long count) const
  547. {
  548.     fFormatter->ReadDoubles(*fSink, buffer, count);
  549. }
  550.  
  551. //----------------------------------------------------------------------------------------
  552. // FW_CReadableStream::operator >>
  553. //----------------------------------------------------------------------------------------
  554.  
  555. inline const FW_CReadableStream& FW_CReadableStream::operator>>(double& aDouble) const
  556. {
  557.     fFormatter->ReadDoubles(*fSink, &aDouble, 1);
  558.     return *this;
  559. }
  560.  
  561. //----------------------------------------------------------------------------------------
  562. // FW_CReadableStream::GetDouble
  563. //----------------------------------------------------------------------------------------
  564.  
  565. inline double FW_CReadableStream::GetDouble() const
  566. {
  567.     double x;
  568.     fFormatter->ReadDoubles(*fSink, &x, 1);
  569.     return x;
  570. }
  571.  
  572. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  573. //----------------------------------------------------------------------------------------
  574. // FW_CReadableStream::Read
  575. //----------------------------------------------------------------------------------------
  576.  
  577. inline void FW_CReadableStream::Read(long double* buffer,
  578.                                      long count) const
  579. {
  580.     fFormatter->ReadLongDoubles(*fSink, buffer, count);
  581. }
  582. #endif
  583.  
  584. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  585. //----------------------------------------------------------------------------------------
  586. // FW_CReadableStream::operator >>
  587. //----------------------------------------------------------------------------------------
  588.  
  589. inline const FW_CReadableStream& FW_CReadableStream::operator>>(long double& aDouble) const
  590. {
  591.     fFormatter->ReadLongDoubles(*fSink, &aDouble, 1);
  592.     return *this;
  593. }
  594. #endif
  595.  
  596. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  597. //----------------------------------------------------------------------------------------
  598. // FW_CReadableStream::GetLongDouble
  599. //----------------------------------------------------------------------------------------
  600.  
  601. inline long double FW_CReadableStream::GetLongDouble() const
  602. {
  603.     long double x;
  604.     fFormatter->ReadLongDoubles(*fSink, &x, 1);
  605.     return x;
  606. }
  607. #endif
  608.  
  609.  
  610. //========================================================================================
  611. //    CLASS FW_CWritableStream
  612. //========================================================================================
  613.  
  614. class FW_CWritableStream : public _FW_CAutoDestructObject
  615. {
  616.  
  617. public:
  618.  
  619.     FW_CWritableStream(FW_CSink* sink,
  620.                        FW_CWritableStreamFormatter* formatter = 0);
  621.     ~FW_CWritableStream();
  622.  
  623.     // ----- void
  624.     
  625.     void Write(const void* buffer,
  626.                long count) const;
  627.         // Write 'count' bytes from buffer.
  628.  
  629. #if !defined(__BORLANDC__)
  630.     // Borland doesn't treat char, unsigned char and signed char as three distinct types
  631.     // as it should. (ARM pg. 22)
  632.  
  633.     // ----- char
  634.     
  635.     void Write(const char* buffer,
  636.                long count) const;
  637.         // Write 'count' chars from buffer.
  638.  
  639.     const FW_CWritableStream& operator<<(const char &aChar) const;
  640.         // Write char.
  641. #endif
  642.  
  643.     const FW_CWritableStream& operator<<(const char *nullTerminatedString) const;
  644.         // Write a null-terminated string.
  645.  
  646.     // ----- signed char
  647.     
  648.     void Write(const signed char* buffer,
  649.                long count) const;
  650.         // Write 'count' signed chars from buffer.
  651.  
  652.     const FW_CWritableStream& operator<<(const signed char &aChar) const;
  653.         // Write signed char.
  654.  
  655.     // ----- unsigned char
  656.     
  657.     void Write(const unsigned char* buffer,
  658.                long count) const;
  659.         // Write 'count' unsigned chars from buffer.
  660.  
  661.     const FW_CWritableStream& operator<<(const unsigned char &aChar) const;
  662.         // Write unsigned char.
  663.  
  664.     // ----- int
  665.  
  666.     void Write(const int* buffer,
  667.                long count) const;
  668.         // Write 'count' ints from buffer.
  669.  
  670.     const FW_CWritableStream& operator<<(const int &aInt) const;
  671.         // Write int.
  672.  
  673.     // ----- unsigned int
  674.  
  675.     void Write(const unsigned int* buffer,
  676.                long count) const;
  677.         // Write 'count' unsigned ints from buffer.
  678.  
  679.     const FW_CWritableStream& operator<<(const unsigned int &unsignedInt) const;
  680.         // Write unsigned int.
  681.  
  682.     // ----- short
  683.  
  684.     void Write(const short* buffer,
  685.                long count) const;
  686.         // Write 'count' shorts from buffer.
  687.  
  688.     const FW_CWritableStream& operator<<(const short &aShort) const;
  689.         // Write short.
  690.  
  691.     // ----- unsigned short
  692.  
  693.     void Write(const unsigned short* buffer,
  694.                long count) const;
  695.         // Write 'count' unsigned shorts from buffer.
  696.  
  697.     const FW_CWritableStream& operator<<(const unsigned short &unsignedShort) const;
  698.         // Write unsigned short.
  699.  
  700.     // ----- long
  701.  
  702.     void Write(const long* buffer,
  703.                long count) const;
  704.         // Write 'count' longs from buffer.
  705.  
  706.     const FW_CWritableStream& operator<<(const long &aLong) const;
  707.         // Write long.
  708.  
  709.     // ----- unsigned long
  710.  
  711.     void Write(const unsigned long* buffer,
  712.                long count) const;
  713.         // Write 'count' unsigned longs from buffer.
  714.  
  715.     const FW_CWritableStream& operator<<(const unsigned long &unsignedLong) const;
  716.         // Write unsigned long.
  717.  
  718.     // ----- float
  719.  
  720.     void Write(const float* buffer,
  721.                long count) const;
  722.         // Write 'count' floats from buffer.
  723.  
  724.     const FW_CWritableStream& operator<<(const float &aFloat) const;
  725.         // Write float.
  726.  
  727.     // ----- double
  728.  
  729.     void Write(const double* buffer,
  730.                long count) const;
  731.         // Write 'count' doubles from buffer.
  732.  
  733.     const FW_CWritableStream& operator<<(const double &aDouble) const;
  734.         // Write double.
  735.  
  736. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  737.  
  738.     // ----- long double
  739.  
  740.     void Write(const long double* buffer,
  741.                long count) const;
  742.         // Write 'count' long doubles from buffer.
  743.  
  744.     const FW_CWritableStream& operator<<(const long double &aDouble) const;
  745.         // Write long double.
  746. #endif
  747.  
  748. protected:
  749.  
  750.     FW_CSink* fSink;
  751.     FW_Boolean fStreamCreatedFormatter;
  752.     FW_CWritableStreamFormatter* fFormatter;
  753.  
  754. private:
  755.     FW_CWritableStream(const FW_CWritableStream& theStream);
  756.     FW_CWritableStream& operator=(const FW_CWritableStream& theStream);
  757.         // Can't copy instances of this class.
  758. };
  759.  
  760. //----------------------------------------------------------------------------------------
  761. // FW_CWritableStream::Write
  762. //----------------------------------------------------------------------------------------
  763.  
  764. inline void FW_CWritableStream::Write(const void* buffer,
  765.                                       long count) const
  766. {
  767.     fFormatter->WriteBytes(*fSink, buffer, count);
  768. }
  769.  
  770. #if !defined(__BORLANDC__)
  771. //----------------------------------------------------------------------------------------
  772. // FW_CWritableStream::Write
  773. //----------------------------------------------------------------------------------------
  774.  
  775. inline void FW_CWritableStream::Write(const char* buffer,
  776.                                       long count) const
  777. {
  778.     fFormatter->WriteChars(*fSink, buffer, count);
  779. }
  780. #endif
  781.  
  782. #if !defined(__BORLANDC__)
  783. //----------------------------------------------------------------------------------------
  784. // FW_CWritableStream::operator <<
  785. //----------------------------------------------------------------------------------------
  786.  
  787. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const char &aChar) const
  788. {
  789.     fFormatter->WriteChars(*fSink, &aChar, 1);
  790.     return *this;
  791. }
  792. #endif
  793.  
  794. //----------------------------------------------------------------------------------------
  795. // FW_CWritableStream::operator<<
  796. //----------------------------------------------------------------------------------------
  797.  
  798. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const char* nullTerminatedString) const
  799. {
  800.     fFormatter->WriteNullTerminatedString(*fSink, nullTerminatedString);
  801.     return *this;
  802. }
  803.  
  804. //----------------------------------------------------------------------------------------
  805. // FW_CWritableStream::Write
  806. //----------------------------------------------------------------------------------------
  807.  
  808. inline void FW_CWritableStream::Write(const signed char* buffer,
  809.                                       long count) const
  810. {
  811.     fFormatter->WriteSignedChars(*fSink, buffer, count);
  812. }
  813.  
  814. //----------------------------------------------------------------------------------------
  815. // FW_CWritableStream::operator <<
  816. //----------------------------------------------------------------------------------------
  817.  
  818. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const signed char &aChar) const
  819. {
  820.     fFormatter->WriteSignedChars(*fSink, &aChar, 1);
  821.     return *this;
  822. }
  823.  
  824. //----------------------------------------------------------------------------------------
  825. // FW_CWritableStream::Write
  826. //----------------------------------------------------------------------------------------
  827.  
  828. inline void FW_CWritableStream::Write(const unsigned char* buffer,
  829.                                       long count) const
  830. {
  831.     fFormatter->WriteUnsignedChars(*fSink, buffer, count);
  832. }
  833.  
  834. //----------------------------------------------------------------------------------------
  835. // FW_CWritableStream::operator <<
  836. //----------------------------------------------------------------------------------------
  837.  
  838. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned char &aChar) const
  839. {
  840.     fFormatter->WriteUnsignedChars(*fSink, &aChar, 1);
  841.     return *this;
  842. }
  843.  
  844. //----------------------------------------------------------------------------------------
  845. // FW_CWritableStream::Write
  846. //----------------------------------------------------------------------------------------
  847.  
  848. inline void FW_CWritableStream::Write(const int* buffer,
  849.                                       long count) const
  850. {
  851.     fFormatter->WriteInts(*fSink, buffer, count);
  852. }
  853.  
  854. //----------------------------------------------------------------------------------------
  855. // FW_CWritableStream::operator <<
  856. //----------------------------------------------------------------------------------------
  857.  
  858. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const int &aInt) const
  859. {
  860.     fFormatter->WriteInts(*fSink, &aInt, 1);
  861.     return *this;
  862. }
  863.  
  864. //----------------------------------------------------------------------------------------
  865. // FW_CWritableStream::Write
  866. //----------------------------------------------------------------------------------------
  867.  
  868. inline void FW_CWritableStream::Write(const unsigned int* buffer,
  869.                                       long count) const
  870. {
  871.     fFormatter->WriteUnsignedInts(*fSink, buffer, count);
  872. }
  873.  
  874. //----------------------------------------------------------------------------------------
  875. // FW_CWritableStream::operator <<
  876. //----------------------------------------------------------------------------------------
  877.  
  878. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned int &unsignedInt) const
  879. {
  880.     fFormatter->WriteUnsignedInts(*fSink, &unsignedInt, 1);
  881.     return *this;
  882. }
  883.  
  884. //----------------------------------------------------------------------------------------
  885. // FW_CWritableStream::Write
  886. //----------------------------------------------------------------------------------------
  887.  
  888. inline void FW_CWritableStream::Write(const short* buffer,
  889.                                       long count) const
  890. {
  891.     fFormatter->WriteShorts(*fSink, buffer, count);
  892. }
  893.  
  894. //----------------------------------------------------------------------------------------
  895. // FW_CWritableStream::operator <<
  896. //----------------------------------------------------------------------------------------
  897.  
  898. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const short &aShort) const
  899. {
  900.     fFormatter->WriteShorts(*fSink, &aShort, 1);
  901.     return *this;
  902. }
  903.  
  904. //----------------------------------------------------------------------------------------
  905. // FW_CWritableStream::Write
  906. //----------------------------------------------------------------------------------------
  907.  
  908. inline void FW_CWritableStream::Write(const unsigned short* buffer,
  909.                                       long count) const
  910. {
  911.     fFormatter->WriteUnsignedShorts(*fSink, buffer, count);
  912. }
  913.  
  914. //----------------------------------------------------------------------------------------
  915. // FW_CWritableStream::operator <<
  916. //----------------------------------------------------------------------------------------
  917.  
  918. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned short &unsignedShort) const
  919. {
  920.     fFormatter->WriteUnsignedShorts(*fSink, &unsignedShort, 1);
  921.     return *this;
  922. }
  923.  
  924. //----------------------------------------------------------------------------------------
  925. // FW_CWritableStream::Write
  926. //----------------------------------------------------------------------------------------
  927.  
  928. inline void FW_CWritableStream::Write(const long* buffer,
  929.                                       long count) const
  930. {
  931.     fFormatter->WriteLongs(*fSink, buffer, count);
  932. }
  933.  
  934. //----------------------------------------------------------------------------------------
  935. // FW_CWritableStream::operator <<
  936. //----------------------------------------------------------------------------------------
  937.  
  938. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const long &aLong) const
  939. {
  940.     fFormatter->WriteLongs(*fSink, &aLong, 1);
  941.     return *this;
  942. }
  943.  
  944. //----------------------------------------------------------------------------------------
  945. // FW_CWritableStream::Write
  946. //----------------------------------------------------------------------------------------
  947.  
  948. inline void FW_CWritableStream::Write(const unsigned long* buffer,
  949.                                       long count) const
  950. {
  951.     fFormatter->WriteUnsignedLongs(*fSink, buffer, count);
  952. }
  953.  
  954. //----------------------------------------------------------------------------------------
  955. // FW_CWritableStream::operator <<
  956. //----------------------------------------------------------------------------------------
  957.  
  958. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const unsigned long &unsignedLong) const
  959. {
  960.     fFormatter->WriteUnsignedLongs(*fSink, &unsignedLong, 1);
  961.     return *this;
  962. }
  963.  
  964. //----------------------------------------------------------------------------------------
  965. // FW_CWritableStream::Write
  966. //----------------------------------------------------------------------------------------
  967.  
  968. inline void FW_CWritableStream::Write(const float* buffer,
  969.                                       long count) const
  970. {
  971.     fFormatter->WriteFloats(*fSink, buffer, count);
  972. }
  973.  
  974. //----------------------------------------------------------------------------------------
  975. // FW_CWritableStream::operator <<
  976. //----------------------------------------------------------------------------------------
  977.  
  978. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const float &aFloat) const
  979. {
  980.     fFormatter->WriteFloats(*fSink, &aFloat, 1);
  981.     return *this;
  982. }
  983.  
  984. //----------------------------------------------------------------------------------------
  985. // FW_CWritableStream::Write
  986. //----------------------------------------------------------------------------------------
  987.  
  988. inline void FW_CWritableStream::Write(const double* buffer,
  989.                                       long count) const
  990. {
  991.     fFormatter->WriteDoubles(*fSink, buffer, count);
  992. }
  993.  
  994. //----------------------------------------------------------------------------------------
  995. // FW_CWritableStream::operator <<
  996. //----------------------------------------------------------------------------------------
  997.  
  998. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const double &aDouble) const
  999. {
  1000.     fFormatter->WriteDoubles(*fSink, &aDouble, 1);
  1001.     return *this;
  1002. }
  1003.  
  1004. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  1005. //----------------------------------------------------------------------------------------
  1006. // FW_CWritableStream::Write
  1007. //----------------------------------------------------------------------------------------
  1008.  
  1009. inline void FW_CWritableStream::Write(const long double* buffer,
  1010.                                       long count) const
  1011. {
  1012.     fFormatter->WriteLongDoubles(*fSink, buffer, count);
  1013. }
  1014. #endif
  1015.  
  1016. #ifdef FW_COMPILER_SUPPORTS_LONG_DOUBLE
  1017. //----------------------------------------------------------------------------------------
  1018. // FW_CWritableStream::operator <<
  1019. //----------------------------------------------------------------------------------------
  1020.  
  1021. inline const FW_CWritableStream& FW_CWritableStream::operator<<(const long double &aDouble) const
  1022. {
  1023.     fFormatter->WriteLongDoubles(*fSink, &aDouble, 1);
  1024.     return *this;
  1025. }
  1026. #endif
  1027.  
  1028. #endif
  1029.